(function() {

var UNDEFINED,
	_guid = 0;

window.rfm = {
    /**
     * Generates a number unique to this browsing session
     * @returns {Number} The unique number
     */
    guid: function() {
        return _guid++;
    },
    /**
     * Substitutes variables into a string
     * @param {String} str The format string, containing indexed substrings ({0}, {1}... {N}) for each argument to merge in
     * @param {Object} args Any number of variables to be merged into the string
     * @returns {String} The formatted string
     */
    format: function(str/*, arg0, arg1, ... argN*/) {
        var result = str,
        	i;
        for (i = arguments.length - 1; i > 0; i--) {
            result.replace('{' + (i - 1) + '}', arguments[i]);
        }
        return result;
    },
    /**
     * Extends a base type
     * @param {Function} ctor The constructor function of the child type
     * @param {Function} parent The constructor function of the parent type
     * @param {Object} overrides (Optional) If specified, overrides and new properties to be applied to the prototype of the child
     */
    extend: function(ctor, parent, overrides) {
        function intermediate() { }
        intermediate.prototype = parent.prototype;
        ctor.prototype = new intermediate();
        ctor.prototype.constructor = ctor;
        if (overrides) {
            for (var prop in overrides) {
                ctor.prototype[prop] = overrides[prop];
            }
        }
    },
    /**
     * Resolves a string to a JavaScript object
     * @param {String} name The property chain leading to the object, relative to the global window object (ie, "rfm.ui.Pagemanager")
     */
	resolve: function(name) {
		var props = name.split('.'),
			i,
			j,
			o = window;
		for (i = 0, j = props.length; i < j; i++) {
			o = o[props[i]];
			if (!o) {
				return UNDEFINED;
			}
		}
		return o;
	}
};

})();